<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:64:"E:\WWW\movie.cc\public/../application/admin\view\movie\edit.html";i:1682319861;}*/ ?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/component/pear/css/pear.css" />
</head>
<body>
    <form class="layui-form">
        <div class="mainBox">
            <div class="main-container">
                <div class="layui-form-item">
                      <label class="layui-form-label">资源名称</label>
                      <div class="layui-input-block">
                        <input type="text" name="name" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" value="<?php echo $data['name']; ?>">
                      </div>
                </div>
                <div class="layui-form-item">
                      <label class="layui-form-label">资源标题</label>
                      <div class="layui-input-block">
                        <input type="text" name="title" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" value="<?php echo $data['title']; ?>">
                      </div>
                </div>
                <div class="layui-form-item">
                      <label class="layui-form-label">会员专享</label>
                      <div class="layui-input-block">
                        <select name="vip">
                          <option value="0" <?php echo $data['vip']=='0'?'selected':''; ?>>选择会员等级</option>
                          <?php if(is_array($vipname) || $vipname instanceof \think\Collection || $vipname instanceof \think\Paginator): $i = 0; $__LIST__ = $vipname;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                          <option value="<?php echo $vo['id']; ?>" <?php echo $data['vip']==$vo['id']?'selected':''; ?>><?php echo $vo['name']; ?></option>
                          <?php endforeach; endif; else: echo "" ;endif; ?>
                          <!-- <option value="0" <?php echo $data['vip']=='0'?'selected':''; ?>>选择会员等级</option>
                          <option value="1" <?php echo $data['vip']=='1'?'selected':''; ?>>月度会员专享</option>
                          <option value="2" <?php echo $data['vip']=='2'?'selected':''; ?>>季度会员专享</option>
                          <option value="3" <?php echo $data['vip']=='3'?'selected':''; ?>>年度会员专享</option>
                          <option value="4" <?php echo $data['vip']=='4'?'selected':''; ?>>永久会员专享</option> -->
                        </select>
                      </div>
                </div>
                <div class="layui-form-item">
                      <label class="layui-form-label">制作商</label>
                      <div class="layui-input-block">
                        <select name="make" lay-verify="required">
                          <option value="">选择制作商</option>
                          <?php if(is_array($makes) || $makes instanceof \think\Collection || $makes instanceof \think\Paginator): $i = 0; $__LIST__ = $makes;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                          <option value="<?php echo $vo['id']; ?>" <?php echo $data['make']==$vo['id']?'selected':''; ?>><?php echo $vo['name']; ?></option>
                          <?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                      </div>
                </div>
                <div class="layui-form-item">
                      <label class="layui-form-label">国家</label>
                      <div class="layui-input-block">
                        <select name="guojia" lay-verify="required">
                          <option value="">选择国家</option>
                          <?php if(is_array($guojias) || $guojias instanceof \think\Collection || $guojias instanceof \think\Paginator): $i = 0; $__LIST__ = $guojias;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                          <option value="<?php echo $vo['id']; ?>" <?php echo $data['guojia']==$vo['id']?'selected':''; ?>><?php echo $vo['name']; ?></option>
                          <?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                      </div>
                </div>
                <div class="layui-form-item">
                      <label class="layui-form-label">栏目</label>
                      <div class="layui-input-block">
                        <?php if(is_array($cols) || $cols instanceof \think\Collection || $cols instanceof \think\Paginator): $i = 0; $__LIST__ = $cols;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                        <input type="checkbox" name="col[]" <?php if(in_array($vo['id'],$colarr)){echo 'checked';} ?> title="<?php echo $vo['name']; ?>" value="<?php echo $vo['id']; ?>">
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                      </div>
                </div>
                <div class="layui-form-item">
                      <label class="layui-form-label">标签</label>
                      <div class="layui-input-block">
                        <?php if(is_array($labels) || $labels instanceof \think\Collection || $labels instanceof \think\Paginator): $i = 0; $__LIST__ = $labels;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                        <input type="checkbox" name="label[]" <?php if(in_array($vo['id'],$labelarr)){echo 'checked';} ?> title="<?php echo $vo['name']; ?>" value="<?php echo $vo['id']; ?>">
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                      </div>
                </div>
                <div class="layui-form-item">
                      <label class="layui-form-label">排序</label>
                      <div class="layui-input-block">
                        <input type="text" name="sort" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input" value="<?php echo $data['sort']; ?>">
                      </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="status" value="1" title="显示" lay-filter="status" <?php echo $data['status']==1?'checked':''; ?>>
                        <input type="radio" name="status" value="2" title="隐藏" lay-filter="status" <?php echo $data['status']==2?'checked':''; ?>>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否最新</label>
                    <div class="layui-input-block">
                        <input type="radio" name="is_new" value="1" title="是" lay-filter="is_new" <?php echo $data['is_new']==1?'checked':''; ?>>
                        <input type="radio" name="is_new" value="2" title="否" lay-filter="is_new" <?php echo $data['is_new']==2?'checked':''; ?>>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否热门</label>
                    <div class="layui-input-block">
                        <input type="radio" name="is_hot" value="1" title="是" lay-filter="is_hot" <?php echo $data['is_hot']==1?'checked':''; ?>>
                        <input type="radio" name="is_hot" value="2" title="否" lay-filter="is_hot" <?php echo $data['is_hot']==2?'checked':''; ?>>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否轮播</label>
                    <div class="layui-input-block">
                        <input type="radio" name="is_banner" value="1" title="是" lay-filter="is_banner" <?php echo $data['is_banner']==1?'checked':''; ?>>
                        <input type="radio" name="is_banner" value="2" title="否" lay-filter="is_banner" <?php echo $data['is_banner']==2?'checked':''; ?>>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">轮播图</label>
                    <div class="layui-input-block">
                          <div class="layui-input-inline" style="width: 500px;">
                            <input type="text"  name="banner" id="banner"  placeholder="请选择轮播图" autocomplete="off" class="layui-input" value="<?php echo $data['banner']; ?>">
                          </div>
                          <div class="layui-input-inline">
                            <button style="float: left;" type="button" class="layui-btn" id="up_banner">上传图片</button>
                          </div>
                    </div> 
                    <div class="layui-input-inline" style="margin-left: 0px;width: 500px;">
                          
                          <div class="layui-input-block">
                            <div style="text-align: center;width: 100px;margin-bottom: 5px;display: flex;" id="bannerbox">
                            </div>
                            <div class="layui-progress layui-progress-big" lay-showpercent="yes" lay-filter="jindu">
                                <div class="layui-progress-bar" lay-percent=""></div>
                            </div>
                          </div>
                    </div> 
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">是否在轮播下</label>
                    <div class="layui-input-block">
                        <input type="radio" name="is_xia" value="1" title="是" lay-filter="is_xia" <?php echo $data['is_xia']==1?'checked':''; ?>>
                        <input type="radio" name="is_xia" value="2" title="否" lay-filter="is_xia" <?php echo $data['is_xia']==2?'checked':''; ?>>
                    </div>
                </div>
                <div class="layui-form-item">
                      <label class="layui-form-label">简述</label>
                      <div class="layui-input-block">
                        <textarea name="desc"   placeholder="请输入简述"   class="layui-textarea" style="height: 200px;width:100%;"><?php echo !empty($data['desc'])?$data['desc']:''; ?></textarea>
                      </div>
                </div>
                <div class="layui-form-item">
                      <label class="layui-form-label">详情</label>
                      <div class="layui-input-block">
                        <textarea name="content" id="content"  placeholder="请输入详情"   class="layui-textarea" style="height: 600px;width:100%;"><?php echo !empty($data['content'])?$data['content']:''; ?></textarea>
                      </div>
                </div>
            </div>
        </div>
        <div class="bottom">
            <div class="button-container">
                <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit="" lay-filter="save">
                    <i class="layui-icon layui-icon-ok"></i>
                    提交
                </button>
                <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </div>
    </form>

<script src="/static/js/jquery-1.8.3.min.js"></script>
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<script>
    function del(obj,path){
        obj.parent().remove();
        $("#banner").val('');
    }
    function del2(obj,path){
        obj.parent().remove();
        $("#icon2").val('');
    }
layui.use(['form','jquery','upload','element','laydate'],function(){
    let form = layui.form;
    let upload = layui.upload;
    let laydate = layui.laydate;
    let element = layui.element;
    let $ = layui.jquery;

    laydate.render({ 
      elem: '#time',
      type:'date'
    });
    var uploadInst = upload.render({
        elem: '#up_banner'
        ,url: '/admin/col/upload'
        ,exts: 'jpg|png|gif|bmp|jpeg'
        ,field:'file'
        ,accept: 'images'   //指定允许上传时校验的文件类型
        ,before: function(obj){
          //预读本地文件示例，不支持ie8
          obj.preview(function(index, file, result){
            $('#banner').attr('src', result); //图片链接（base64）
          });
          element.progress('jindu', '0%'); //进度条复位
          layer.msg('上传中', {icon: 16, time: 0});
        }
        ,done: function(res){
            console.log(res)
          //如果上传失败
          if(res.code > 0){
            return layer.msg('上传失败');
          }else{
            $("#banner").val(res.data);
            str=`<div class="layui-input-inline">
                                    <img class="layui-upload-img" style="width: 100px;" src="${res.data}">
                                    <button style="margin-top: 5px;" type="button" class="layui-btn layui-btn-xs" onclick="del($(this),'${res.data}')">删除</button>
                                </div>`
          }
          $('#bannerbox').html(str); 
          // $('#bannerText').html(''); 
        }
        ,error: function(){
          var imgText = $('#imgText');
          imgText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs img-reload">重试</a>');
          imgText.find('.img-reload').on('click', function(){
            uploadInst.upload();
          });
        }
        //进度条
        ,progress: function(n, index, e){
          element.progress('jindu', n + '%'); 
          if(n == 100){
            layer.msg('上传成功',{icon:1})
          }else{
            layer.msg('上传失败', {icon: 2});
          }
        }
      });
     //自定义验证规则
    // form.verify({
    //   username:[/^[A-Za-z0-9_]{6,12}$/,'用户名必须是6到12位，由字母下划线数字组成'],
    //   pass: [/^[\S]{6,12}$/,'密码必须6到12位，且不能出现空格'],
    //   num:[/^\d+$/,'得是整数'],
    //   price:[/(^[1-9]\d*(\.\d{1,2})?$)|(^0(\.\d{1,2})?$)/,'注意价格格式'],
    //   head_portrait:function(value){
    //     if(!value){
    //       return '请上传头像';
    //     }
    //   }
    // });
    form.on('submit(save)', function(data){
        console.log(data.field)
        // return;
        $.ajax({
            data:JSON.stringify(data.field),
            dataType:'json',
            contentType:'application/json',
            type: 'post',
            success:function(res){
                if(res.code==1){
                    layer.msg(res.msg,{icon:1,time:1000},function(){
                        parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        parent.layui.table.reload("dataTable");
                    });
                }else{
                    layer.msg(res.msg,{icon:2,time:1000});
                }
            }
        })
        return false;
    });
})
</script>
<script type="text/javascript" charset="utf-8" src="/static/admin/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/admin/ueditor/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/admin/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">

    var ue = UE.getEditor('content',{ zIndex: 10});
</script>
</body>
</html>